﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using DAL;
using DomainModel;
using System.Text.RegularExpressions;
namespace BL
{
    class BLTool
    {
        /*
            isNull: make sure that object is null or not
         */ 
        public static Boolean isNull(Object customer )
        {return (customer == null) ? true : false ;}
        /*
            IsEmptyString: make sure that it is empty string or not
         */
        public static Boolean isEmptyString(String words)
        {return (words == "") ? true : false;}
        

        /*
         * isNotZipCode: make sure that zip code has 5 digits.
         */

        /*Regualr expression ver*/
        public static Boolean isNotZipCode(int zipcode)
        {
           string zip = "";
           int convertInt = zipcode;
 
            zip = convertInt.ToString();
            return (!Regex.Match(zip, @"^(\d{5}-\d{4}|\d{5}|\d{9})$|^([a-zA-Z]\d[a-zA-Z] \d[a-zA-Z]\d)$").Success);
        }

        public static Boolean isRightEmail(string email)
        {
            return (!Regex.Match(email, @"^(?("")("".+?""@)|(([0-9a-zA-Z]((\.(?!\.))|[-!#\$%&'\*\+/=\?\^`\{\}\|~\w])*)(?<=[0-9a-zA-Z])@))(?(\[)(\[(\d{1,3}\.){3}\d{1,3}\])|(([0-9a-zA-Z][-\w]*[0-9a-zA-Z]\.)+[a-zA-Z]{2,6}))$").Success);
        }

        /*
         * Binary number check 0 or 1 
         */
        public static Boolean isBinary(int binary)
        { return ((binary == 0) || (binary == 1) ? true : false); }


        public static Boolean isNagetive(int number) 
        {
            return (number < 0) ? true : false;
        }

        

        /*
         * isValidID: make sure that ID is positive.
         * Note: need to check this -- ID might start at 0..
         */
        public static Boolean isNotValidID(int id)
        { 
            return ((id < 0) ? true : false);
        }

        //checks if product id is valid for InsertOrderItems()
        public static Boolean isValidProductId(int id)
        {
            return ((id >= 0 || id <= 215) ? true : false);
        }

         

    }
}
